package cj.web.marry.dao;

import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;

/**
 * 
 * @author 
 *
 */
@DAO
public interface VideosDAO{
	
	@SQL("select c.id,c.title,c.image,c.video,c.type,b.man,b.manCard,b.woman,b.womanCard from MarriageInfor b  join MarriageVideo c on b.id = c.marriageInforId"
			+ " where b.code=:1 ORDER BY b.id DESC LIMIT :2,:3 ")
    List<Map> queryMarriageVideosByTitle(String code,int start,int length);
	
	@SQL("select count(1) from MarriageInfor b  join MarriageVideo c on b.id = c.marriageInforId where b.code=:1 ")
    int queryMarriageVideosByTitleSize(String code);
	
//	@SQL("select count(1) from UserApplication a join MarriageInfor b on a.id = b.code join MarriageVideo c on b.id = c.marriageInforId where b.title=:1 ")
//    int queryMarriageVideosByTypeSize(String title);
    
//	@SQL("select a.id,a.openid,b.title,c.image,c.video,c.type,b.man,b.manCard,b.woman,b.womanCard from UserApplication a join MarriageInfor b on a.id = b.code join MarriageVideo c on b.id = c.marriageInforId"
//			+ " where a.id =:1 and c.type=:2 ")
//    List<Map> queryMarriageVideosByType(int id,int type);
	
	@SQL("select a.id,a.openid,b.title,c.image,c.video,c.type,b.man,b.manCard,b.woman,b.womanCard from UserApplication a join MarriageInfor b on a.id = b.code join MarriageVideo c on b.id = c.marriageInforId"
			+ " where a.openid =:1 ")
    List<Map> queryMarriageVideosByOpenId(String openId);
	
	@SQL("select c.id,c.title,c.image,c.video,c.type,b.man,b.manCard,b.woman,b.womanCard from MarriageInfor b join MarriageVideo c on b.id = c.marriageInforId"
			+ " where c.id =:1 ")
    List<Map> queryMarriageVideosById(int id);
	
	@SQL("select a.id,a.openid,b.title,b.photo,b.man,b.manCard,b.woman,b.womanCard from UserApplication a join MarriageInfor b on a.id = b.code "
			+ " where a.openid =:1 ")
	List<Map> queryMarriagePhotosByOpenId(String openid);
	
	@SQL("SELECT count(1) FROM MarriagePhotoRef  WHERE code =:1 ")
    int queryMarriagePhotoRefSize(String code);
    
    @SQL("select code,photo from MarriagePhotoRef where code=:1 ")
    List<Map> queryMarriagePhotoReflis(String code);
}